#include <iostream>
#include <stdio.h>
using namespace std;
typedef long long LL;
LL getT(LL a, LL b) {
    int ret = 0;
    while (a < b) {
        a = a * 2;
        ++ret;
    }
    return ret;
}

int main() {
    LL W,H,w,h;
    while (cin>>W>>H) {
        scanf("%I64d %I64d", &w, &h);
        LL res = -1;
        if (!(w<=W && h<=H)) swap(w, h);
        if (w<=W && h<=H) res = getT(w, W) + getT(h, H);
        swap(w, h);
        if (w<=W && h<=H) res = min(getT(w, W)+getT(h, H), res);
        printf("%I64d\n", res);
    }
    return 0;
}
